/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-20 16:40:38
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-20 16:54:47
 */
import 'package:flutter/material.dart';
import 'package:flutter_data_center/components/animation_text.dart';
import 'package:flutter_data_center/controller/school_attendance_controller.dart';
import 'package:flutter_data_center/utills/color_utils.dart';
import 'package:get/get.dart';

class CardStatistic extends StatelessWidget {
  const CardStatistic({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) => GetBuilder<SchoolAttendanceController>(
        builder: (_controller) => Container(
          height: 130,
          width: double.infinity,
          padding: EdgeInsets.all(10),
          decoration: BoxDecoration(
            color: gColor("#08D187"),
            borderRadius: BorderRadius.circular(10),
          ),
          child: Column(
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    "到校总数",
                    style: TextStyle(fontSize: 13, color: Colors.white),
                  ),
                  Container(
                    width: 36,
                    height: 16,
                    decoration: BoxDecoration(
                      color: gColor("#C1FDE7"),
                      borderRadius: BorderRadius.circular(30),
                    ),
                    child: Center(
                      child: Text(
                        "当月",
                        style: TextStyle(
                          fontSize: 9,
                          color: gColor("#08D187"),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.start,
                children: [
                  AnimText(
                    number: _controller.total,
                    style: TextStyle(
                      fontSize: 24,
                      color: Colors.white,
                      fontWeight: FontWeight.w700,
                    ),
                  ),
                  SizedBox(width: 17),
                  Text(
                    "人",
                    style: TextStyle(
                      fontSize: 12,
                      color: Colors.white,
                    ),
                  ),
                ],
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.start,
                children: [
                  buildItem(_controller.late, "迟到"),
                  SizedBox(width: 37),
                  buildItem(_controller.personal, "请假"),
                  SizedBox(width: 37),
                  buildItem(_controller.leave, "早退"),
                ],
              ),
            ],
          ),
        ),
      );

  Row buildItem(int count, String label) {
    return Row(
      children: [
        Text(
          label,
          style: TextStyle(
            fontSize: 12,
            color: gColor("#ACFBDE"),
          ),
        ),
        SizedBox(width: 8),
        AnimText(
          number: count,
          style: TextStyle(
            fontSize: 18,
            color: Colors.white,
          ),
        ),
      ],
    );
  }
}
